package com.tjec.project.projectWorkbench.service.impl;

import java.util.List;
import com.tjec.common.utils.DateUtils;
import com.tjec.common.utils.StringUtils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.tjec.project.projectWorkbench.mapper.BmsReportNoMapper;
import com.tjec.project.projectWorkbench.domain.BmsReportNo;
import com.tjec.project.projectWorkbench.service.IBmsReportNoService;

/**
 * 报告号Service业务层处理
 * 
 * @author tjec
 * @date 2020-07-20
 */
@Service
public class BmsReportNoServiceImpl implements IBmsReportNoService 
{
    @Autowired
    private BmsReportNoMapper bmsReportNoMapper;

    /**
     * 查询报告号
     * 
     * @param guid 报告号ID
     * @return 报告号
     */
    @Override
    public BmsReportNo selectBmsReportNoByGuid(String guid)
    {
        return bmsReportNoMapper.selectBmsReportNoByGuid(guid);
    }

    /**
     * 查询报告号列表
     * 
     * @param bmsReportNo 报告号
     * @return 报告号
     */
    @Override
    public List<BmsReportNo> selectBmsReportNoList(BmsReportNo bmsReportNo)
    {
        return bmsReportNoMapper.selectBmsReportNoList(bmsReportNo);
    }

    /**
     * 新增报告号
     * 
     * @param bmsReportNo 报告号
     * @return 结果
     */
    @Override
    public String insertBmsReportNo(BmsReportNo bmsReportNo)
    {
    	if(StringUtils.isNotBlank(bmsReportNo.getGuid())) {
    		bmsReportNoMapper.updateBmsReportNo(bmsReportNo);
    	}else {
    		 bmsReportNo.setCreateTime(DateUtils.getNowDate());
    	     bmsReportNoMapper.insertBmsReportNo(bmsReportNo);
    	}
       
        return bmsReportNo.getGuid();
    }

    /**
     * 修改报告号
     * 
     * @param bmsReportNo 报告号
     * @return 结果
     */
    @Override
    public int updateBmsReportNo(BmsReportNo bmsReportNo)
    {
        return bmsReportNoMapper.updateBmsReportNo(bmsReportNo);
    }

    /**
     * 批量删除报告号
     * 
     * @param guids 需要删除的报告号ID
     * @return 结果
     */
    @Override
    public int deleteBmsReportNoByGuids(String[] guids)
    {
        return bmsReportNoMapper.deleteBmsReportNoByGuids(guids);
    }

    /**
     * 删除报告号信息
     * 
     * @param guid 报告号ID
     * @return 结果
     */
    @Override
    public int deleteBmsReportNoByGuid(String guid)
    {
        return bmsReportNoMapper.deleteBmsReportNoByGuid(guid);
    }

	@Override
	public Integer checkBmsReportNo(BmsReportNo bmsReportNo) {
		return bmsReportNoMapper.checkBmsReportNo(bmsReportNo);
	}

	@Override
	public List<BmsReportNo> selectReportTypeAndNoList(BmsReportNo bmsReportNo) {
		return bmsReportNoMapper.selectReportTypeAndNoList(bmsReportNo);
	}

    @Override
    public int updateBmsReportNoByReportNo(BmsReportNo bmsReportNo) {
        return bmsReportNoMapper.updateBmsReportNoByReportNo(bmsReportNo);
    }

	@Override
	public List<BmsReportNo> selectReportsByBusinessId(String businessId) {
		return bmsReportNoMapper.selectReportsByBusinessId(businessId);
	}
}
